package view;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

import model.*;

/* Cette classe s'occupe de l'affichage de la fen�tre de sommaire */
public class SommaireUi extends JFrame{

	private static final long serialVersionUID = 1L;

	private String strHeader = "-------------------------------------------------------------\n"+
	  						   "                  Systeme de livraison"+
	  						   "\n-------------------------------------------------------------";
	
	private JTextArea txtHeader;
	private JTextArea txtDetailsCommande;
	private JButton btnOk= new JButton("OK");
	Restaurant Resto;
	boolean SelectionHd;
	int Somme =0;
	
    
    public SommaireUi()
    {
    	this.Resto=Resto;
  		Container content = getContentPane();
  		//content.setSize(400, 300);
  		content.setLayout(new BorderLayout());
		
		txtHeader = new JTextArea();
		txtHeader.setText(strHeader);
		
		JPanel headerPanel = new JPanel();
		headerPanel.setLayout(new FlowLayout());
		headerPanel.add(txtHeader,BorderLayout.CENTER);
		txtHeader.setEditable(false);
		content.add(headerPanel,BorderLayout.NORTH);
	
		ModelFacade mf = ModelFacade.getInstance();
		
		txtDetailsCommande = new JTextArea(mf.getCurrentCommande().toStringSommaire());
		txtDetailsCommande.setSize(450, 650);
    			
		JPanel detailsPanel = new JPanel();
    	detailsPanel.setLayout(new GridLayout(1,1,10,10));
    	detailsPanel.add(txtDetailsCommande);
    	
    	txtDetailsCommande.setEditable(false);
    	JScrollPane detailsScroll=new JScrollPane(txtDetailsCommande);
    	detailsPanel.add(detailsScroll);
  
		
    	JPanel mainPanel = new JPanel();
		mainPanel.setLayout(new GridLayout(1,1,30,30));
		mainPanel.add(detailsPanel);
    	content.add(mainPanel, BorderLayout.CENTER);
    	JPanel btnPanel = new JPanel();
    	btnPanel.setLayout(new FlowLayout());
    	btnPanel.add(btnOk);
		content.add(btnPanel,BorderLayout.SOUTH);
		setSize(450,450);
    	content.setVisible(true);
    	setVisible(true);
    }
    
    public void addBtnOkListener(ActionListener listener){
    	btnOk.addActionListener(listener);
    }



    
}
